Skip to content

Commit

Permalink
Values/Validates/Actions namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Sep 9, 2024
1 parent 921e25e commit 42df566
Show file tree
Hide file tree
Showing 105 changed files with 768 additions and 846 deletions.
8 changes: 4 additions & 4 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class_alias('Yakamara\YForm\Choice\View', 'rex_yform_choice_view');

// Manager

rex_complex_perm::register('yform_manager_table_edit', 'Yakamara\YForm\Manager\Table\Perm\Edit');
rex_complex_perm::register('yform_manager_table_view', 'Yakamara\YForm\Manager\Table\Perm\View');
rex_complex_perm::register('yform_manager_table_edit', '\Yakamara\YForm\Manager\Table\Perm\Edit');
rex_complex_perm::register('yform_manager_table_view', '\Yakamara\YForm\Manager\Table\Perm\View');

if (rex::isBackend() && rex::getUser()) {
rex_extension::register('PACKAGES_INCLUDED', function () {
Expand Down Expand Up @@ -181,8 +181,8 @@ class_alias('Yakamara\YForm\Choice\View', 'rex_yform_choice_view');
$this->setProperty('pages', $pages);
}

rex_extension::register('MEDIA_IS_IN_USE', 'rex_yform_value_be_media::isMediaInUse');
rex_extension::register('PACKAGES_INCLUDED', 'rex_yform_value_be_link::isArticleInUse');
rex_extension::register('MEDIA_IS_IN_USE', '\Yakamara\YForm\Value\BackendMedia::isMediaInUse');
rex_extension::register('PACKAGES_INCLUDED', '\Yakamara\YForm\Value\BackendLink::isArticleInUse');

rex_extension::register('YFORM_SAVED', static function (rex_extension_point $ep) {
if ($ep->getSubject() instanceof Exception) {
Expand Down
4 changes: 2 additions & 2 deletions fragments/yform/manager/page/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static function ($params) {
if (isset($params['list']->getParams()['table_name'])) {
$target_table = $params['list']->getParams()['table_name'];
$target_field = $tablefield[0];
$values = rex_yform_value_be_manager_relation::getListValues($target_table, $target_field);
$values = \Yakamara\YForm\Value\BackendManagerRelation::getListValues($target_table, $target_field);
$value = $values[$params['list']->getValue('id')];
}
} else {
Expand All @@ -111,7 +111,7 @@ static function ($params) {
$target_table = $fields[$field_name]->getElement('table');
$target_field = $fields[$field_name]->getElement('field');

$values = rex_yform_value_be_manager_relation::getListValues(
$values = \Yakamara\YForm\Value\BackendManagerRelation::getListValues(
$target_table,
$target_field,
);
Expand Down
11 changes: 3 additions & 8 deletions lib/yform/base_abstract.php → lib/AbstractBase.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

abstract class rex_yform_base_abstract
namespace Yakamara\YForm;

abstract class AbstractBase
{
public $id;
public $params = [];
Expand Down
15 changes: 15 additions & 0 deletions lib/Action/AbstractAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Yakamara\YForm\Action;

use Yakamara\YForm\AbstractBase;

abstract class AbstractAction extends AbstractBase
{
public $action = [];

protected function getElementMappingOffset()
{
return 1;
}
}
14 changes: 6 additions & 8 deletions lib/yform/action/callback.php → lib/Action/Callback.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_action_callback extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use function call_user_func;
use function in_array;

class Callback extends AbstractAction
{
public static $callback_actions = [
'pre',
Expand Down
9 changes: 2 additions & 7 deletions lib/yform/action/copy_value.php → lib/Action/CopyValue.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
namespace Yakamara\YForm\Action;

class rex_yform_action_copy_value extends rex_yform_action_abstract
class CopyValue extends AbstractAction
{
public function executeAction(): void
{
Expand Down
15 changes: 7 additions & 8 deletions lib/yform/action/create_table.php → lib/Action/CreateTable.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_action_create_table extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use rex;
use rex_sql;
use function in_array;

class CreateTable extends AbstractAction
{
public function executeAction(): void
{
Expand Down
38 changes: 11 additions & 27 deletions lib/yform/action/db.php → lib/Action/Db.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

declare(strict_types=1);

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
class rex_yform_action_db extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use Exception;
use rex;
use rex_extension;
use rex_extension_point;
use rex_sql;
use function call_user_func;
use function count;

class Db extends AbstractAction
{
public function executeAction(): void
{
Expand Down Expand Up @@ -68,8 +70,6 @@ public function executeAction(): void
$action = 'insert';
$id = $sql->getLastId();
$this->params['main_id'] = $id;
/** @deprecated since 3.4.1 use id (lowercase) instead */
$this->params['value_pool']['email']['ID'] = $id;
$this->params['value_pool']['email']['id'] = $id;
}
} catch (Exception $e) {
Expand Down Expand Up @@ -103,22 +103,6 @@ public function executeAction(): void
'yform' => true,
],
));

/**
* @deprecated since 3.4.1 use EP YFORM_SAVED instead
*/
rex_extension::registerPoint(new rex_extension_point(
'REX_YFORM_SAVED',
$sql,
[
'form' => $this,
'sql' => $sql,
'table' => $main_table,
'action' => $action,
'id' => $this->params['main_id'],
'yform' => true,
],
));
}
}

Expand Down
14 changes: 6 additions & 8 deletions lib/yform/action/db_query.php → lib/Action/DbQuery.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_action_db_query extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use Exception;
use rex_sql;

class DbQuery extends AbstractAction
{
public function executeAction(): void
{
Expand Down
13 changes: 6 additions & 7 deletions lib/yform/action/email.php → lib/Action/Email.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
namespace Yakamara\YForm\Action;

class rex_yform_action_email extends rex_yform_action_abstract
use rex_mailer;

use function is_array;

class Email extends AbstractAction
{
public function executeAction(): void
{
Expand Down
17 changes: 7 additions & 10 deletions lib/yform/action/encrypt_value.php → lib/Action/EncryptValue.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_action_encrypt_value extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use function function_exists;
use function in_array;

class EncryptValue extends AbstractAction
{
public function executeAction(): void
{
$f = $this->getElement(3); // the function
if (!function_exists($f)) {
$f = 'md5';
} // default func = md5
}

// Labels to get
$l = explode(',', $this->getElement(2));
Expand All @@ -28,7 +26,6 @@ public function executeAction(): void
return;
}

// $this->params["value_pool"]["sql"] = Array for database
$k = '';
foreach ($this->params['value_pool']['sql'] as $key => $value) {
if (in_array($key, $l)) {
Expand Down
9 changes: 2 additions & 7 deletions lib/yform/action/html.php → lib/Action/Html.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
namespace Yakamara\YForm\Action;

class rex_yform_action_html extends rex_yform_action_abstract
class Html extends AbstractAction
{
public function executeAction(): void
{
Expand Down
29 changes: 4 additions & 25 deletions lib/yform/action/manage_db.php → lib/Action/ManageDb.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
namespace Yakamara\YForm\Action;

class rex_yform_action_manage_db extends rex_yform_action_abstract
use rex_sql;

class ManageDb extends AbstractAction
{
public function executeAction(): void
{
// START - Spezialfall "be_em_relation"
/*
$be_em_table_field = "";
if($this->params["value_pool"]["sql"]["type_name"] == "be_em_relation")
{
$be_em_table_field = $this->params["value_pool"]["sql"]["f1"];
$this->params["value_pool"]["sql"]["f1"] = $this->params["value_pool"]["sql"]["f3"]."_".$this->params["value_pool"]["sql"]["f1"];
}
*/
// ENDE - Spezialfall

// ********************************* TABLE A

// $this->params["debug"]= TRUE;
$sql = rex_sql::factory();
$sql->setDebug($this->params['debug']);

$main_table = '';
if ('' != $this->getElement(2)) {
$main_table = $this->getElement(2);
} else {
Expand Down Expand Up @@ -76,15 +58,12 @@ public function executeAction(): void
if ('' != $where) {
$sql->setWhere($where);
$sql->update();
$flag = 'update';
} else {
$sql->insert();
$flag = 'insert';
$id = $sql->getLastId();

$this->params['value_pool']['email']['ID'] = $id;
$this->params['main_id'] = $id;
// $this->params["value_pool"]["sql"]["ID"] = $id;
if (0 == $id) {
$this->params['form_show'] = true;
$this->params['hasWarnings'] = true;
Expand Down
4 changes: 3 additions & 1 deletion lib/yform/action/php.php → lib/Action/Php.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class rex_yform_action_php extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

class Php extends AbstractAction
{
public function executeAction(): void
{
Expand Down
13 changes: 6 additions & 7 deletions lib/yform/action/readtable.php → lib/Action/ReadTable.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/
namespace Yakamara\YForm\Action;

class rex_yform_action_readtable extends rex_yform_action_abstract
use rex_sql;

use function count;

class ReadTable extends AbstractAction
{
public function executeAction(): void
{
Expand Down
14 changes: 6 additions & 8 deletions lib/yform/action/redirect.php → lib/Action/Redirect.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

/**
* yform.
*
* @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_action_redirect extends rex_yform_action_abstract
namespace Yakamara\YForm\Action;

use function count;
use function is_array;

class Redirect extends AbstractAction
{
public function executeAction(): void
{
Expand Down
Loading

0 comments on commit 42df566

Please sign in to comment.