Completed
Branch master (78c2af)
by Pierre-Henry
52:17 queued 17:37
created

app/system/core/forms/ConfirmCoreForm.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Core / Form
7
 */
8
namespace PH7;
9
10
defined('PH7') or exit('Restricted access');
11
12
use PH7\Framework\Mvc\Router\Uri;
13
14
class ConfirmCoreForm
15
{
16
   /**
17
    * @param array $aParam The parameters
18
    * @return void
19
    */
20
    public static function display(array $aParam)
21
    {
22
        $sUrl = Uri::get($aParam['module'], $aParam['controller'], $aParam['action']);
23
24
        $oForm = new \PFBC\Form('form_confirm');
25
        $oForm->configure(array('action'=>$sUrl));
26
        $oForm->addElement(new \PFBC\Element\Hidden('submit_confirm', 'form_confirm'));
27
        $oForm->addElement(new \PFBC\Element\Token(substr($sUrl, -14, -6))); // Create a name token and generate a random token
28
        $oForm->addElement(new \PFBC\Element\Hidden('id', $aParam['id']));
29
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2>' . t('Are you sure you want to do this?') . '</h2>'));
30
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="err_msg s_marg">' . t('Warning, this action is irreversible!') . '</p>'));
31
        $oForm->addElement(new \PFBC\Element\Button($aParam['label'], 'submit'));
32
        /**
33
         * Bug Ajax jQuery -> https://github.com/jquery/jquery-mobile/issues/3202
34
         * $oForm->addElement(new \PFBC\Element\Button($aParam['label'], 'submit', array('formaction'=>$sUrl)));
35
         */
36
        $oForm->addElement(new \PFBC\Element\Button(t('Cancel'), 'cancel', array('onclick'=>'$("form").attr("action", "");parent.$.colorbox.close();return false'))); // Bug fixes
37
        $oForm->render();
38
    }
39
}
40